<?php

Class Evaluation extends CI_Model {
    
    function get_last() {
        $this->db->select('*');
        $this->db->from('evaluation');
        $this->db->order_by('id', 'desc');
        
        $query = $this->db->get();
        return $query->row_array();
    }
    
    function get_list() {
        
        $this->db->select('*');
        $this->db->from('evaluation');
        $this->db->order_by("id", "desc");
        
        $query = $this->db->get();

        if ($query->num_rows() >= 1) {
            return $query->result();
        } else {
            return false;
        }
    }
    
    function get($id) {
        $query = $this->db->get_where('evaluation', array('id' => $id));
        return $query->row_array();
    }
    
    function insert($newEvaluation) {
        if ($this->db->insert('evaluation', $newEvaluation)) {
            return "Đã thêm!";
        } else {
            return "Unable to add";
        }
    }
    
    function update($newEvaluation)
    {
        $this->db->where('id', $newEvaluation['id']);
        $this->db->update('evaluation', $newEvaluation);
        return "Đã cập nhật!";
    }
    
    function delete($id) {
        $this->db->delete('evaluation', array('id' => $id));
        return "Đã xóa!";
        
    }

}

?>
